function values(t)
    local i = 0
    return function ()
        i = i + 1;
        return t[i] 
    end
end
t = {10,20,30}
iter = values(t)
while(true) do
    local ele = iter()
    if ele == nil then
        break
    end
    print(ele)
end
print()
for ele in values(t) do
    print(ele)
end
function allwords()
    local line = io.read()
    local pos = 1
    return function () 
        while line do 
            local w,e = string.match(line,"(%w+)()",pos)
            if w  then
                pos = e
                return w
            else
                line = io.read()
                pos = 1
            end
            end
    return nil
    end
end
for word in allwords() do
    print(word)
end
-- pair 无序遍历 ipairs 有序 因为索引